Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Expose esprima-fb's "Syntax" #29

Merged
merged 1 commit into from
Sep 21, 2014
Merged

Expose esprima-fb's "Syntax" #29

merged 1 commit into from
Sep 21, 2014

Conversation

zertosh
Copy link
Contributor

@zertosh zertosh commented Sep 11, 2014

This PR exposes require('esprima-fb').Syntax from jstransform/src/utils and updates the references to it throughout.

Motivation: I find myself doubly including esprima-fb because of the weird version numbers it uses and my need to reach Syntax. The most visible example of this is with envify (used by React), which requires jstransform and esprima-fb. Since the jstransform version can float, you end up in a situation where jstransform uses X version of esprima-fb, but envify is using Y version solely for the Syntax object.

Hopefully if this gets merged, I'll make a pull request to simplify envify and maybe we can bump envify in React's next release.

@zpao
Copy link
Contributor

zpao commented Sep 11, 2014

I think this is a reasonable thing but I'll defer to @jeffmo. If we take it my instinct here is to not export it from utils but from jstransform itself, or maybe even just export esprima itself. But I haven't actually looked closely at our source here and don't know the structure well.

@sophiebits
Copy link
Contributor

Perhaps the most reasonable thing to do is use peer dependencies here, if esprima-fb version compatibility is important.

@jeffmo
Copy link
Contributor

jeffmo commented Sep 11, 2014

This is a good idea. I don't like exporting all of esprima, but Syntax is really useful when writing a transform. You are often doing comparisons with Syntax.<<whatever>> -- so having a version of Syntax that's in sync with whatever JSTransform.transform used internally makes a lot of sense.

I'll agree with @zpao that this makes a tiny bit more sense to be exported from jstransform directly (not the utils module -- it's not really a utility function). I don't feel super strongly about this, it's just an aesthetic intuition I think.

@zertosh
Copy link
Contributor Author

zertosh commented Sep 11, 2014

@jeffmo: makes sense. I've rebased the changes.

I went back to the modules requiring Syntax directly from esprima-fb. Otherwise, there would be a gross circular dependency between jstransform.js and utils.js. I considered creating a Syntax.js that simply had module.exports.Syntax = require('esprima-fb').Syntax;, but then that felt weird.

cc: @zpao

@zertosh
Copy link
Contributor Author

zertosh commented Sep 15, 2014

Just a friendly ping @jeffmo and @zpao

@zpao
Copy link
Contributor

zpao commented Sep 15, 2014

I'll let @jeffmo make the final merge here since he owns this more than me. He's been on stage at a conference today but I'm sure he'll get to it this week.

@zertosh
Copy link
Contributor Author

zertosh commented Sep 21, 2014

This would also simplify react-tools's deps

diff --git a/package.json b/package.json
index 2a7f4476..2548659b 100644
--- a/package.json
+++ b/package.json
@@ -34,3 +34,2 @@
     "commoner": "^0.10.0",
-    "esprima-fb": "^6001.1.0-dev-harmony-fb",
     "jstransform": "^6.2.0"
diff --git a/vendor/fbtransform/transforms/react.js b/vendor/fbtransform/transforms/react.js
index 11ed7a8f..088c0245 100644
--- a/vendor/fbtransform/transforms/react.js
+++ b/vendor/fbtransform/transforms/react.js
@@ -18,3 +18,3 @@

-var Syntax = require('esprima-fb').Syntax;
+var Syntax = require('jstransform').Syntax;
 var utils = require('jstransform/src/utils');
diff --git a/vendor/fbtransform/transforms/reactDisplayName.js b/vendor/fbtransform/transforms/reactDisplayName.js
index 7d974a0d..50dc85d2 100644
--- a/vendor/fbtransform/transforms/reactDisplayName.js
+++ b/vendor/fbtransform/transforms/reactDisplayName.js
@@ -18,3 +18,3 @@

-var Syntax = require('esprima-fb').Syntax;
+var Syntax = require('jstransform').Syntax;
 var utils = require('jstransform/src/utils');
diff --git a/vendor/fbtransform/transforms/xjs.js b/vendor/fbtransform/transforms/xjs.js
index fb2f7fb8..8aac7c58 100644
--- a/vendor/fbtransform/transforms/xjs.js
+++ b/vendor/fbtransform/transforms/xjs.js
@@ -17,3 +17,3 @@
 "use strict";
-var Syntax = require('esprima-fb').Syntax;
+var Syntax = require('jstransform').Syntax;
 var utils = require('jstransform/src/utils');

jeffmo added a commit that referenced this pull request Sep 21, 2014
@jeffmo jeffmo merged commit 8ba7ff0 into facebookarchive:master Sep 21, 2014
@jeffmo
Copy link
Contributor

jeffmo commented Sep 21, 2014

version 6.3.2 published

@zertosh
Copy link
Contributor Author

zertosh commented Sep 21, 2014

thanks @jeffmo!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants